{include file="common/header" /}
<div class="page-body">
    <div class="container-xl">
        <div class="row row-cards">
            <div class="col-md-12 offset-md-0">
                <div class="card">
                    <div class="card-header">
                        <h4 class="card-title">下发列表</h4>
                    </div>
                    <div class="table-responsive">
                        <table class="table table-vcenter card-table">
                            <thead>
                              <tr>
                                <th>ID</th>
                                <th>编号</th>
                                <th>产品型号</th>
                                <th>申请人类型</th>
                                <th>申请用户</th>
                                <th>申请数量</th>
                                <th>申请时间</th>
                                <th>产品规范</th>
                                <th>客户源文件</th>
                                <th>状态</th>
                                <th>操作</th>
                              </tr>
                            </thead>
                            <tbody>
                                {foreach $issueList as $key=>$vo } 
                                  <tr>
                                    <td class="text-secondary">
                                        {$vo.id}
                                    </td>
                                    <td class="text-secondary">
                                        {$vo.product_no}
                                    </td>
                                    <td class="text-secondary">
                                        {$vo.model}
                                    </td>
                                    <td class="text-secondary">
                                        {:getUserType($vo.user_type)}
                                    </td>
                                    <td class="text-secondary">
                                        {$vo.nickname}
                                    </td>
                                    <td class="text-secondary">
                                        {$vo.num}
                                    </td>
                                    <td class="text-secondary">
                                        {$vo.apply_time}
                                    </td>
                                    <td class="text-secondary">
                                        <a href="/index/home/getFile?url={$vo.standard_file_url}&name={$vo.standard_file_name}">
                                          {$vo.standard_file_name}
                                        </a>
                                      </td>
                                      <td class="text-secondary">
                                        <a href="/index/home/getFile?url={$vo.source_file_url}&name={$vo.source_file_name}">
                                          {$vo.source_file_name}
                                        </a>
                                    </td>
                                    <td class="text-secondary">
                                        {if $vo.status == 1}
                                        <span class="badge bg-success-lt">已处理</span>
                                        {/if}
                                        {if $vo.status ==2}
                                        <span class="badge bg-lt">已取消</span>
                                        {/if}
                                        {if $vo.status == 0}
                                        <span class="badge bg-warning-lt">待处理</span>
                                        {/if}
                                    </td>
                                    <td class="text-secondary">
                                        {if $userInfo.role == 1 && $vo.status == 0}
                                        <span onclick="handle('{$vo.id}')" class="badge bg-primary-lt">处理</span>
                                        {/if}
                                        {if $userInfo.role == 3 && $vo.status == 0}
                                        <span onclick="cancel('{$vo.id}')" class="badge bg-lt">取消</span>
                                        {/if}
                                    </td>
                                  </tr>
                                {/foreach}
                            </tbody>
                          </table>
                    </div>
                  </div>
            </div>
        </div>
    </div>
</div>
{include file="common/footer" /}

<script>
function handle(id){
    axios.post('/index/issue/handle',{
        id:id
    })
    .then(function (res) {
        layer.msg(res.data.msg)
        if(res.data.code == 200){
            window.location.href = ""
        }
    })
    .catch(function (error) {
        console.log(error);
    });
}

function cancel(id){
    axios.post('/index/issue/cancel',{
        id:id
    })
    .then(function (res) {
        layer.msg(res.data.msg)
        if(res.data.code == 200){
            window.location.href = ""
        }
    })
    .catch(function (error) {
        console.log(error);
    })
}
</script>

